
//打印
import htmlToPdf from "@/utils/htmlToPdf";
import {PaperSizes} from "@/utils/PaperSizes";

function init() {
  this.generatePdfInstance = this.$generatePdfFile({
    headerHeight: this.headerHeight,
    footerHeight: this.footerHeight,
  });
  //横板
  this.pageHeight = this.generatePdfInstance.options.a4W;
  this.pageWidth = this.generatePdfInstance.options.a4H;
}

function getEls() {
  let part1El = this.$refs.print.querySelectorAll(".page-cont");
  this.els = [part1El];
  return {
    pagesEl: this.els,
  };
}

async function getPdf(){
  let elsOptions = this.getEls();
  let info = await this.generatePdfInstance.generateFile(elsOptions);
  this.$modal.msgSuccess("即将开始下载文件，请稍等");
  this.generatePdfInstance.exportFile(this.content.title);
  this.generatePdfInstance.resetFile();
}

async function getNewPdf( dom, title){
  htmlToPdf.getPdf(dom,{
    title:title,
    paper:PaperSizes.A4F,
    direction:'l'
  });
}

export default function defaultPrint(dom, nickName, userName) {
  getNewPdf(dom, nickName, userName);
}
